#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
微信实名认证查询模型
"""

from typing import Dict, Any
from jlpay.model.base import OrgBaseReq, BaseResponse


class RealnameWxQueryRequest(OrgBaseReq):
    """微信实名认证查询请求"""
    
    API_URL = "/open/merch/access/wechat/realname/query"
    
    def __init__(self):
        """初始化微信实名认证查询请求"""
        super().__init__()
        self.merch_no = ""  # 商户号
        self.query_type = "0"  # 查询类型，0-申请单查询（默认），1-授权结果查询
    
    def set_merch_no(self, merch_no):
        """
        设置商户号
        
        Args:
            merch_no: 商户号
            
        Returns:
            RealnameWxQueryRequest实例
        """
        self.merch_no = merch_no
        return self
    
    def set_query_type(self, query_type):
        """
        设置查询类型
        
        Args:
            query_type: 查询类型，0-申请单查询（默认），1-授权结果查询
            
        Returns:
            RealnameWxQueryRequest实例
        """
        self.query_type = query_type
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """
        转换为字典格式
        
        Returns:
            字典格式的数据
        """
        data = super().to_dict()
        if self.merch_no:
            data['merch_no'] = self.merch_no
        if self.query_type:
            data['query_type'] = self.query_type
        return data


class RealnameWxQueryResponse(BaseResponse):
    """微信实名认证查询响应"""
    
    def __init__(self, response_dict=None):
        """
        初始化微信实名认证查询响应
        
        Args:
            response_dict: 响应字典
        """
        super().__init__(response_dict)
        self.applyment_status = None  # 申请状态
        self.qrcode_data = None  # 二维码链接地址
        self.reject_param = None  # 驳回字段
        self.reject_reason = None  # 审核驳回原因
        self.authorize_state = None  # 授权状态
        
        if response_dict:
            self.applyment_status = response_dict.get('applyment_status')
            self.qrcode_data = response_dict.get('qrcode_data')
            self.reject_param = response_dict.get('reject_param')
            self.reject_reason = response_dict.get('reject_reason')
            self.authorize_state = response_dict.get('authorize_state')
    
    def to_dict(self) -> Dict[str, Any]:
        """
        转换为字典格式
        
        Returns:
            字典格式的数据
        """
        data = super().to_dict()
        if self.applyment_status:
            data['applyment_status'] = self.applyment_status
        if self.qrcode_data:
            data['qrcode_data'] = self.qrcode_data
        if self.reject_param:
            data['reject_param'] = self.reject_param
        if self.reject_reason:
            data['reject_reason'] = self.reject_reason
        if self.authorize_state:
            data['authorize_state'] = self.authorize_state
        return data 